package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

/**
 * between 表达式解析内容
 * 
 * @author zwd
 *
 */
public class ExpressionBetweenContext extends BaseExpressionParseContext {

	private boolean isNot = false;

	// ExpressionBetweenMinValueContext
	private BaseExpressionParseContext minValue;

	// ExpressionBetweenMaxValueContext
	private BaseExpressionParseContext maxValue;

	public boolean isNot() {
		return isNot;
	}

	public void setNot(boolean isNot) {
		this.isNot = isNot;
	}

	public BaseExpressionParseContext getMinValue() {
		return minValue;
	}

	public void setMinValue(BaseExpressionParseContext minValue) {
		this.minValue = minValue;
	}

	public BaseExpressionParseContext getMaxValue() {
		return maxValue;
	}

	public void setMaxValue(BaseExpressionParseContext maxValue) {
		this.maxValue = maxValue;
	}

	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		// TODO Auto-generated method stub

	}

	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		/*
		 * expressionBetween : identifierNot? KW_BETWEEN
		 * expressionBetweenMinValue KW_AND expressionBetweenMaxValue ;
		 */
		StringBuilder sb = new StringBuilder();
		if (isNot) {
			sb.append(" NOT ");
		}
		sb.append(" BETWEEN ");
		sb.append(minValue.toString());
		sb.append(" AND ");
		sb.append(maxValue.toString());
		return sb.toString();
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		// TODO Auto-generated method stub

	}

}
